﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using System.Xml.Linq;
using System.Collections.Generic;
using MediaWiki.Common;
using MediaWiki.Office.Model.Utilities;

namespace MediaWiki.Office.Model
{
  public class Field : InlineContent
  {
    public const string LocalName = "fldSimple";
    public static readonly XName Name = Document.WordprocessingML + LocalName;

    private IList<InlineContent> _content = new List<InlineContent>();
    private string _codes;

    public string Codes
    {
      get { return _codes; }
      set { _codes = value; }
    }

    public IList<InlineContent> Content
    {
      get { return _content; }
    }

    public Field(Paragraph parent, XElement element)
      : base(parent, element)
    {
      XNamespace ns = element.Name.Namespace;

      _codes = (string)element.Attribute(ns + "instr");

      _content.AddRange(InlineContent.Create(Parent, element.Elements()));
    }

    public override InlineContentType ContentType
    {
      get { return InlineContentType.Field; }
    }
  }
}